package com.zego.wawaji.third.pay.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.zego.wawaji.base.data.BaseData;

import org.json.JSONObject;

/**
 * 微信支付
 */
public class PayWX extends BaseData implements Parcelable {

    private String app_id;
    private String mch_id;
    private String prepay_id;
    private String nonce_str;
    private String sign;   // 不是PayReq所需sign， 所需sign需要自己去拼接

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(getJsonObject(jsonStr).optString("Url"));

        this.setApp_id(jsonObject.optString("appid"));
        this.setMch_id(jsonObject.optString("mch_id"));
        this.setPrepay_id(jsonObject.optString("prepay_id"));
        this.setNonce_str(jsonObject.optString("nonce_str"));
        this.setSign(jsonObject.optString("sign"));
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getNonce_str() {
        return nonce_str;
    }

    public void setNonce_str(String nonce_str) {
        this.nonce_str = nonce_str;
    }

    public String getApp_id() {
        return app_id;
    }

    public void setApp_id(String app_id) {
        this.app_id = app_id;
    }

    public String getMch_id() {
        return mch_id;
    }

    public void setMch_id(String mch_id) {
        this.mch_id = mch_id;
    }

    public String getPrepay_id() {
        return prepay_id;
    }

    public void setPrepay_id(String prepay_id) {
        this.prepay_id = prepay_id;
    }

    public PayWX() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.app_id);
        dest.writeString(this.mch_id);
        dest.writeString(this.prepay_id);
        dest.writeString(this.nonce_str);
        dest.writeString(this.sign);
    }

    protected PayWX(Parcel in) {
        this.app_id = in.readString();
        this.mch_id = in.readString();
        this.prepay_id = in.readString();
        this.nonce_str = in.readString();
        this.sign = in.readString();
    }

    public static final Creator<PayWX> CREATOR = new Creator<PayWX>() {
        @Override
        public PayWX createFromParcel(Parcel source) {
            return new PayWX(source);
        }

        @Override
        public PayWX[] newArray(int size) {
            return new PayWX[size];
        }
    };
}